﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CF_DAL_WS.Models;

namespace CF_DAL_WS.DTO
{
    public class FoodTypeDTO
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public List<RestaurantDTO> Restaurants { get; set; }

        public static FoodTypeDTO Translate(FoodType Entity)
        {
            if (Entity != null)
            {
                var dto = new FoodTypeDTO
                {
                    ID = Entity.ID,
                    Name = Entity.Name,
                    Restaurants = new List<RestaurantDTO>()
                };
                if (Entity.Restaurant != null)
                {
                    foreach (var item in Entity.Restaurant)
                    {
                        dto.Restaurants.Add(RestaurantDTO.Translate(item));
                    }
                }
                return dto;
            }
            return null;
        }

        public static FoodTypeDTO TranslateBase(FoodType Entity)
        {
            if (Entity != null)
            {
                var dto = new FoodTypeDTO
                {
                    ID = Entity.ID,
                    Name = Entity.Name
                };
                return dto;
            }
            return null;
        }

        public static FoodType Reverse(FoodTypeDTO obj)
        {
            var entity = new FoodType
            {
                Name = obj.Name
            };
            return entity;
        }

        public void UpdateEntity(ref FoodType entity)
        {
            entity.Name = Name;
        }
    }
}